<?if($this->count > 0):?>
	<?foreach($this->results AS $result):?>
	
		<?php
		/* get hits per day */
		$current_hits 	= $result['count_hits'];
		$timestamp		= (time()-$this->datetime($result['create_date'], null, false, true));
		$days 			= $timestamp/60/60/24;
		$hits_per_day	= round($current_hits/$days, 2);
		?>

		<h1><?=MHDEV_Sprintf($this->translate->_('profile_header'), array('%user' => $this->escape($result['username'])))?></h1>
		
		<p><a href="<?=$this->url(array('controller' => 'index'),'index', true)?>">Forum</a><?=$this->getRootline(false, false, $result['uid'])?></p>
		
		<ul class="profile_tabs">
		<li>
			<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/magnifier.png" alt="" title="" />
			<span><?=$this->translate->_('profile_details')?></span>
		</li>
			
		<li>
			<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/book.png" alt="" title="" />
			<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'guestbook', 'uid' => $result['uid']), 'profile_gb', true)?>">
				<?=$this->translate->_('profile_guestbook')?>
			</a> <span style="color:#666;">(<?=$this->gb_count?>)</span>
		</li>
		
		<?if($this->checkBuddy):?>
			<li>
				<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/heart.png" alt="" title="" />
				<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'addbuddy', 'uid' => $result['uid']), 'profile_addbuddy', true)?>">
					<?=$this->translate->_('profile_add_buddy')?>
				</a>
			</li>
		<?endif;?>
		
		<?if($this->auth_uid == $result['uid']):?>
			<li>
				<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/pencil.png" alt="" title="" />
				<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'edit'), 'profile_edit', true)?>">
					<?=$this->translate->_('profile_edit')?>
				</a>
			</li>
			<li>
				<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/image.png" alt="" title="" />
				<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'avatar'), 'profile_ava', true)?>">
					<?=$this->translate->_('profile_edit_ava')?>
				</a>
			</li>
		<?endif;?>
		</ul>
		<br style="clear:left;" />
		
		<div class="profile_avatar"><?=$this->GetUserAvatar($result['uid'])?></div>
		
		<ul class="profile_list">
			<li><span><?=$this->translate->_('profile_forename')?></span> <?=$result['forename']?></li>
			<li><span><?=$this->translate->_('profile_lastname')?></span> <?=$result['lastname']?></li>
			<li><span><?=$this->translate->_('profile_dateofbirth')?></span> <?=$result['date_of_birth']?></li>
			<li><span><?=$this->translate->_('profile_city')?></span> <?=$result['city']?></li>
			<li><span><?=$this->translate->_('profile_zip')?></span> <?=$result['zip']?></li>
			<li><span><?=$this->translate->_('profile_homepage')?></span> <?=$result['homepage']?></li>
			<li><span><?=$this->translate->_('profile_hits')?></span> <?=$result['count_hits']?> <span style="color:#666; font-size:0.8em;">(<?=$hits_per_day?> <?=$this->translate->_('profile_hitsperday')?>)</span></li>
			<li><span><?=$this->translate->_('profile_posts')?></span> <?=$result['count_posts']?></li>
			<li><span><?=$this->translate->_('profile_threads')?></span> <?=$result['count_threads']?></li>
			<li><span><?=$this->translate->_('profile_joined')?></span> <?=$this->datetime($result['create_date'])?></li>
		</ul>
		
		<br />
		
		<div class="profile_buddies">
		<h2><?=$this->translate->_('profile_buddies')?></h2>
		<?if($this->buddy_count > 0):?>
			<?foreach($this->buddy_res AS $buddies):?>
				<dl class="profile_buddy">
					<dt><a href="<?=$this->url(array('controller' => 'profile', 'uid' => $buddies['buddy_uid']), 'profile', true)?>"><?=$this->GetAuthor($buddies['buddy_uid'])?></a></dt>
					<dd><?=$this->GetUserAvatar($buddies['buddy_uid'])?></dd>
					<?if($this->auth_uid == $result['uid']):?>
						<dd>
							<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'setbuddy', 'uid' => $buddies['buddy_uid'], 'mode' => 'delete'), 'buddy_mode', true)?>">
								<img src="<?=$this->baseUrl()?>/static/gfx/icons/bin.png" alt="<?=$this->translate->_('buddy_delete')?>" title="<?=$this->translate->_('buddy_delete')?>" />
							</a>
						</dd>
					<?endif;?>
				</dl>
			<?endforeach;?>
			<br style="clear:left;" />
		<?else:?>
			<p class="notice"><?=$this->translate->_('profile_buddies_error')?></p>
		<?endif;?>
		</div>
		
		<div class="profile_last10">
		<h2><?=$this->translate->_('profile_last10')?></h2>
		
		<?if($this->post_count > 0):?>
			<br />
			<ul class="profile_list">
			<?foreach($this->post_results AS $pResult):?>
				<li>
					<span>
						<a href="<?=$this->url(array('controller' => 'posts', 'uid' => $pResult['thread_uid'], 'title' => $this->escape($this->CleanUrlTitle($pResult['title']))), 'threads', true)?>">
							<?=$this->escape($pResult['title'])?>
						</a>
					</span> 
					<?=MHDEV_Sprintf($this->translate->_('profile_last10_date'), array('%board' => $this->escape($pResult['bTitle']), '%created'  => $this->datetime($pResult['create_date'], 'dd. MMMM yy HH:m', true), '%last_date' => $this->datetime($pResult['last_reply_date'], 'dd. MMMM yy HH:m', true)))?>
				</li>
			<?endforeach;?>
			</ul>
		<?else:?>
			<p class="notice"><?=$this->translate->_('profile_last10_error')?></p>
		<?endif;?>
		</div>
		
	<?endforeach;?>
<?else:?>
	<h1><?=$this->translate->_('error_profile_header')?></h1>
	<p class="notice_bad"><?=$this->translate->_('error_profile_text')?></p>
<?endif;?>